﻿var lmsArray = [];
lmsArray[47] = [0.261254, 11.34566, 0.186716]; // '47.5' in the supplied data
lmsArray[48] = [0.258986, 11.63413, 0.186724];
lmsArray[49] = [0.254448, 12.21147, 0.18674];
lmsArray[50] = [0.249902, 12.78999, 0.186757];
lmsArray[51] = [0.245348, 13.36976, 0.186773];
lmsArray[52] = [0.240786, 13.9508, 0.186789];
lmsArray[53] = [0.236218, 14.5327, 0.186806];
lmsArray[54] = [0.231648, 15.11491, 0.186822];
lmsArray[55] = [0.227075, 15.69732, 0.186839];
lmsArray[56] = [0.222501, 16.27968, 0.186855];
lmsArray[57] = [0.217927, 16.86186, 0.186871];
lmsArray[58] = [0.213354, 17.44364, 0.186888];
lmsArray[59] = [0.208779, 18.02536, 0.186904];
lmsArray[60] = [0.204195, 18.60813, 0.186921];
lmsArray[61] = [0.199591, 19.19364, 0.186938];
lmsArray[62] = [0.194952, 19.78411, 0.186954];
lmsArray[63] = [0.190264, 20.3818, 0.186971];
lmsArray[64] = [0.185513, 20.98909, 0.186988];
lmsArray[65] = [0.180684, 21.60829, 0.187006];
lmsArray[66] = [0.175771, 22.24043, 0.187024];
lmsArray[67] = [0.170774, 22.88553, 0.187042];
lmsArray[68] = [0.165698, 23.54292, 0.187061];
lmsArray[69] = [0.160549, 24.21185, 0.187079];
lmsArray[70] = [0.155323, 24.89288, 0.187099];
lmsArray[71] = [0.150019, 25.58613, 0.187118];
lmsArray[72] = [0.144644, 26.29073, 0.187138];
lmsArray[73] = [0.139212, 27.00431, 0.187158];
lmsArray[74] = [0.133727, 27.72582, 0.187179];
lmsArray[75] = [0.128199, 28.45382, 0.187199];
lmsArray[76] = [0.122631, 29.18755, 0.18722];
lmsArray[77] = [0.117026, 29.92662, 0.187241];
lmsArray[78] = [0.111387, 30.67021, 0.187263];
lmsArray[79] = [0.105722, 31.41724, 0.187284];
lmsArray[80] = [0.100036, 32.16656, 0.187306];
lmsArray[81] = [0.0943, 32.91732, 0.187328];
lmsArray[82] = [0.0886, 33.66879, 0.187351];
lmsArray[83] = [0.0829, 34.42044, 0.187373];
lmsArray[84] = [0.0772, 35.17218, 0.187396];
lmsArray[85] = [0.0714, 35.92416, 0.187419];
lmsArray[86] = [0.0656, 36.67657, 0.187442];
lmsArray[87] = [0.0599, 37.42941, 0.187465];
lmsArray[88] = [0.0541, 38.18268, 0.187489];
lmsArray[89] = [0.0483, 38.93634, 0.187513];
lmsArray[90] = [0.0425, 39.68972, 0.187537];
lmsArray[91] = [0.0366, 40.44245, 0.187561];
lmsArray[92] = [0.030784, 41.19418, 0.187586];
lmsArray[93] = [0.0249, 41.94491, 0.187611];
lmsArray[94] = [0.019077, 42.69462, 0.187636];
lmsArray[95] = [0.0132, 43.44349, 0.187662];
lmsArray[96] = [0.00732, 44.19156, 0.187687];
lmsArray[97] = [0.00141, 44.93907, 0.187714];
lmsArray[98] = [-0.00451, 45.68615, 0.18774];
lmsArray[99] = [-0.0104, 46.43288, 0.187767];
lmsArray[100] = [-0.01641, 47.17943, 0.187794];
lmsArray[101] = [-0.0224, 47.92592, 0.187822];
lmsArray[102] = [-0.0284, 48.67273, 0.18785];
lmsArray[103] = [-0.0345, 49.42077, 0.187878];
lmsArray[104] = [-0.0405, 50.17117, 0.187907];
lmsArray[105] = [-0.0467, 50.92488, 0.187937];
lmsArray[106] = [-0.0529, 51.68263, 0.187967];
lmsArray[107] = [-0.0591, 52.44502, 0.187997];
lmsArray[108] = [-0.0654, 53.21351, 0.188029];
lmsArray[109] = [-0.0718, 53.98868, 0.188061];
lmsArray[110] = [-0.0783, 54.77184, 0.188094];
lmsArray[111] = [-0.08483, 55.564, 0.188128];
lmsArray[112] = [-0.09147, 56.36608, 0.188162];
lmsArray[113] = [-0.09822, 57.17921, 0.188198];
lmsArray[114] = [-0.10506, 58.00458, 0.188234];
lmsArray[115] = [-0.11203, 58.84351, 0.188272];
lmsArray[116] = [-0.11911, 59.69722, 0.18831];
lmsArray[117] = [-0.12633, 60.56714, 0.18835];
lmsArray[118] = [-0.13368, 61.4543, 0.188391];
lmsArray[119] = [-0.14116, 62.35979, 0.188434];
lmsArray[120] = [-0.14879, 63.28413, 0.188478];
lmsArray[121] = [-0.15657, 64.22863, 0.188523];
lmsArray[122] = [-0.16451, 65.19349, 0.18857];
lmsArray[123] = [-0.17259, 66.1794, 0.188618];
lmsArray[124] = [-0.18083, 67.18694, 0.188668];
lmsArray[125] = [-0.18923, 68.21635, 0.188719];
lmsArray[126] = [-0.19779, 69.26768, 0.188772];
lmsArray[127] = [-0.20651, 70.34142, 0.188827];
lmsArray[128] = [-0.21539, 71.43801, 0.188884];
lmsArray[129] = [-0.22443, 72.55832, 0.188942];
lmsArray[130] = [-0.23364, 73.70374, 0.189002];
lmsArray[131] = [-0.24303, 74.87627, 0.189065];
lmsArray[132] = [-0.25259, 76.07749, 0.189129];
lmsArray[133] = [-0.26233, 77.3086, 0.189195];
lmsArray[134] = [-0.27224, 78.5706, 0.189263];
lmsArray[135] = [-0.28234, 79.8646, 0.189334];
lmsArray[136] = [-0.29261, 81.19117, 0.189407];
lmsArray[137] = [-0.30306, 82.55081, 0.189482];
lmsArray[138] = [-0.31368, 83.94411, 0.189559];
lmsArray[139] = [-0.32447, 85.37162, 0.189639];
lmsArray[140] = [-0.33544, 86.83343, 0.18972];
lmsArray[141] = [-0.34658, 88.32863, 0.189805];
lmsArray[142] = [-0.35787, 89.85613, 0.189891];
lmsArray[143] = [-0.36933, 91.41457, 0.18998];
lmsArray[144] = [-0.38093, 93.00259, 0.190071];
lmsArray[145] = [-0.39268, 94.61938, 0.190164];
lmsArray[146] = [-0.40457, 96.26445, 0.190259];
lmsArray[147] = [-0.41661, 97.93725, 0.190357];
lmsArray[148] = [-0.42877, 99.63726, 0.190457];
lmsArray[149] = [-0.44107, 101.3643, 0.190559];
lmsArray[150] = [-0.4535, 103.1185, 0.190663];
lmsArray[151] = [-0.46605, 104.9003, 0.190769];
lmsArray[152] = [-0.47872, 106.7104, 0.190877];
lmsArray[153] = [-0.49152, 108.5509, 0.190987];
lmsArray[154] = [-0.50444, 110.424, 0.191099];
lmsArray[155] = [-0.51747, 112.3314, 0.191213];
lmsArray[156] = [-0.53062, 114.2748, 0.191329];
lmsArray[157] = [-0.54389, 116.2553, 0.191447];
lmsArray[158] = [-0.55726, 118.274, 0.191566];
lmsArray[159] = [-0.57074, 120.3305, 0.191688];
lmsArray[160] = [-0.58432, 122.4227, 0.191811];
lmsArray[161] = [-0.59798, 124.5476, 0.191936];
lmsArray[162] = [-0.61173, 126.7027, 0.192062];
lmsArray[163] = [-0.62556, 128.8849, 0.19219];
lmsArray[164] = [-0.63945, 131.0918, 0.19232];
lmsArray[165] = [-0.6534, 133.3214, 0.19245];
lmsArray[166] = [-0.66741, 135.572, 0.192583];
lmsArray[167] = [-0.68147, 137.8425, 0.192716];
lmsArray[168] = [-0.69558, 140.1322, 0.19285];
lmsArray[169] = [-0.70973, 142.4401, 0.192986];
lmsArray[170] = [-0.72392, 144.7655, 0.193122];
lmsArray[171] = [-0.73814, 147.1068, 0.193259];
lmsArray[172] = [-0.7524, 149.4619, 0.193398];
lmsArray[173] = [-0.76667, 151.8295, 0.193537];
lmsArray[174] = [-0.78097, 154.2079, 0.193676];
lmsArray[175] = [-0.79529, 156.595, 0.193817];
lmsArray[176] = [-0.80962, 158.989, 0.193957];
lmsArray[177] = [-0.82396, 161.389, 0.194099];
lmsArray[178] = [-0.83831, 163.7942, 0.19424];
lmsArray[179] = [-0.85266, 166.2038, 0.194382];
lmsArray[180] = [-0.86703, 168.6179, 0.194524];
lmsArray[181] = [-0.8814, 171.0371, 0.194667];
lmsArray[182] = [-0.89578, 173.4621, 0.194809];
lmsArray[183] = [-0.91016, 175.8924, 0.194952];
lmsArray[184] = [-0.92455, 178.3274, 0.195095];
lmsArray[185] = [-0.93894, 180.7666, 0.195238];
lmsArray[186] = [-0.95334, 183.2098, 0.195381];
lmsArray[187] = [-0.96774, 185.6562, 0.195525];
lmsArray[188] = [-0.98215, 188.1056, 0.195668];
lmsArray[189] = [-0.99655, 190.5575, 0.195811];
lmsArray[190] = [-1.01096, 193.0109, 0.195955];
lmsArray[191] = [-1.02536, 195.4649, 0.196098];

var mean = [];
var lower = [];
var upper = [];

for (var i = 47; i <= 191; i++) {
    var lambda = lmsArray[i][0];
    var mu = lmsArray[i][1];
    var sigma = lmsArray[i][2];

    mean.push([i, mu]);
    //upper
    up = 2 * lambda * sigma;
    up += 1;
    up = Math.pow(up, (1 / lambda)) * mu;

    upper.push([i, up]);

    //lower
    low = -2 * lambda * sigma;
    low += 1;
    low = Math.pow(low, (1 / lambda)) * mu;

    lower.push([i, low]);

}

var datasets = [
{ data: upper, label: 'Upper' },
{ data: mean, label: 'Mean' },
{ data: lower, label: 'Lower' }
];

function plot1() {
    $.plot($("#placeholder"),
    datasets, {
    //options
    yaxis: {
        min: 1,
        max: 400
    },
    xaxis: {
        tickDecimals: 0
    },
    crosshair: { mode: 'xy' },
    grid: { hoverable: true }

})
}

function plot2() {
    $.plot($("#placeholder"),
    datasets, {
        //options
    yaxis: {
            min: 1,
            max: 400,
            transform: function(v) { return Math.log(v); } ,
            inverseTransform: function(v) { return Math.exp(v); }

        },
        xaxis: {
            tickDecimals: 0,
            transform: function(v) { return Math.log(v); },
            inverseTransform: function(v) { return Math.exp(v); }

        },
        crosshair: { mode: 'xy' },
        grid: { hoverable: true }

    })
}

$(function() {
plot1();

$('#Radio1').click(plot1);
$('#Radio2').click(plot2);

$("#placeholder").bind("plothover", function(event, pos, item) {
    $("#x").text(pos.x.toFixed(2));
    $("#y").text(pos.y.toFixed(2));
});
});